package com.woniu.communitymanagement.controller;

import com.woniu.communitymanagement.entity.House;
import com.woniu.communitymanagement.entity.HttpResult;
import com.woniu.communitymanagement.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/house")
@CrossOrigin(origins = "*")
public class HouseController {
    @Autowired
    private HouseService houseService;
    @RequestMapping("/list")
    public HttpResult getHouseList(String number, Integer pageIndex, Integer pageSize){
        return houseService.getHouseList(number,pageIndex,pageSize);
    }
    @RequestMapping("/delete")
    public HttpResult deleteById(Integer id){
        return houseService.deleteById(id);
    }
    @RequestMapping("/update")
    public  HttpResult updateById(@RequestBody House house){
        return houseService.updateHouseById(house);
    }
    @RequestMapping("/insert")
    public HttpResult insertHouse(@RequestBody House house){
        return houseService.insertHouse(house);
    }
    @RequestMapping("/selectOne")
    public HttpResult selectOne(Integer id){
        return houseService.selectOne(id);
    }
    @RequestMapping("/all")
    public HttpResult selectAll(){
        return houseService.selectAll();
    }

}
